<?php

namespace app\api\controller;

use app\common\model\NumberCardTemplate;
use app\common\model\RechargeTemplate;
use app\common\model\MonthCardTemplate;

/**
 * 会员卡模版控制器
 * @package app\index\controller
 */
class Template extends Auth
{
    public $noNeedLogin = '';

    public function _initialize()
    {
        parent::initialize();
        if (!$this->request->isPost())
            $this->result('请求错误','',204);
    }

    /**
     * 获取会员卡模版列表
     * @param $type
     */
    public function lists()
    {
        $data = $this->request->post();

        switch ($data['type'])
        {
            case 1:
                $list = RechargeTemplate::where(['store_id'=>$this->userInfo['id'],'viper_type_id'=>$data['viper_type_id']])->select();
                 break;
            case 2:
                $list = NumberCardTemplate::where(['store_id'=>$this->userInfo['id'],'viper_type_id'=>$data['viper_type_id']])->select();

                break;
            case 3:
                $list = MonthCardTemplate::where(['store_id'=>$this->userInfo['id'],'viper_type_id'=>$data['viper_type_id']])->select();
                break;
        }

        $list = empty($list)?[]:$list;

        $this->result('获取成功',$list,200);
    }




}
